<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/Home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card class="box-card">
            <el-table :data="rightslist"  border :header-cell-style="{textAlign: 'center'}" :cell-style="{textAlign: 'center'}"  stripe>
                <el-table-column type="index" label="序号" width="100"></el-table-column>
                <el-table-column prop="authName" label="权限名称"></el-table-column>
                <el-table-column prop="path" label="路径"></el-table-column>
                <el-table-column prop="level" label="权限等级">
                    <template slot-scope="scope">
                        <el-tag type="success" v-if="scope.row.level=='0'">一级</el-tag>
                        <el-tag type="info" v-else-if="scope.row.level=='1'">二级</el-tag>
                        <el-tag type="warning" v-else>三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
export default {
    created(){
        this.getrightslist();
    },
    data() {
        return {
            rightslist:[],
        }
    },
    methods: {
        getrightslist:async function() {
            const {data:res} =await this.$http.get("rights/list");
            console.log(res);
            if(res.meta.status==200) {
                this.rightslist=res.data;
            }
            else {
                this.$alert("请求数据失败","消息提示",{
                    confirmButtonText: "确定"
                })
            } 
        }
    }
}
</script>

<style scoped>
* {
    margin: 0;
    padding: 0;
  }
.el-breadcrumb {
    margin-left: 170px;
    margin-top: 20px;
    margin-bottom: 20px;
}
.el-breadcrumb-item {
    font-size: 20px;
}
.box-card {
    width: 1200px;
    margin: 0 auto;
}
.el-table {
    margin-top: 20px;
}
</style>